package org.codert.wxpay.config;

import org.codert.wxpay.support.WxPayClientFactory;
import org.codert.wxpay.support.client.WxPayClient;
import org.codert.wxpay.support.properties.WxPayProperties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;


/**
 * @author: TanJingyu
 * @create: 2021-08-12 15:12
 **/
@Configuration(proxyBeanMethods = false)
@Import(HttpClientConfiguration.class)
@EnableConfigurationProperties(WxPayProperties.class)
@ComponentScan(basePackages = "org.codert.wxpay.support.client")
public class WxPayConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public WxPayClientFactory wxPayClient(ObjectProvider<WxPayClient> wxPayClients) {
        return new WxPayClientFactory(wxPayClients);
    }
}
